package com.yeziji.common.business.dataMessage.entity.table;

import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.table.TableDef;


/**
* 消息记录表 表定义层。
*
* @author system
* @since 2024-10-29
*/
public class DataMessageRecordTableDef extends TableDef {

    private static final long serialVersionUID = 1L;

    /**
     * 消息记录表
     */
    public static final DataMessageRecordTableDef DATA_MESSAGE_RECORD = new DataMessageRecordTableDef();

    /**
     * 自增 id
     */
    public final QueryColumn ID = new QueryColumn(this, "id");

    /**
     * 消息上报 IP
     */
    public final QueryColumn IP = new QueryColumn(this, "ip");

    /**
     * 消息主题
     */
    public final QueryColumn TOPIC = new QueryColumn(this, "topic");

    /**
     * 消息唯一键
     */
    public final QueryColumn FLAG_ID = new QueryColumn(this, "flag_id");

    /**
     * 消息状态：DataSyncStatusEnum
     */
    public final QueryColumn STATUS = new QueryColumn(this, "status");

    /**
     * 消费信息
     */
    public final QueryColumn MESSAGE = new QueryColumn(this, "message");

    /**
     * 消息消费间隔
     */
    public final QueryColumn SLEEP_TIME = new QueryColumn(this, "sleep_time");

    /**
     * 重试次数
     */
    public final QueryColumn RETRY_COUNT = new QueryColumn(this, "retry_count");

    /**
     * 消息相关数据
     */
    public final QueryColumn CORRELATION_DATA = new QueryColumn(this, "correlation_data");

    /**
     * 创建时间
     */
    public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");

    /**
     * 更新时间
     */
    public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");

    /**
     * 所有字段。
     */
    public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");

    /**
     * 默认字段，不包含逻辑删除或者 large 等字段。
     */
    public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, IP, TOPIC, FLAG_ID, MESSAGE, CORRELATION_DATA, STATUS, RETRY_COUNT, SLEEP_TIME, CREATE_TIME, UPDATE_TIME};

    public DataMessageRecordTableDef() {
        super("", "data_message_record");
    }

    private DataMessageRecordTableDef(String schema, String name, String alisa) {
        super(schema, name, alisa);
    }

    public DataMessageRecordTableDef as(String alias) {
        String key = getNameWithSchema() + "." + alias;
        return getCache(key, k -> new DataMessageRecordTableDef("", "data_message_record", alias));
    }

}